package javabean.reflect;

import java.lang.reflect.Method;

/**
 * @author leon(liangzou0318@gmail.com)
 * @date 2012-4-15
 * @filaname util.java

 */
public class util {
	public static Base convertStr2ServiceBean(String beanName,String fieldSetter,String paraValue){
		 Base base = null ; 
		try {
		 Class cls = Class.forName(beanName) ;
		 base = (Base)cls.newInstance() ;
		 Class[] paraTypes = new Class[]{String.class };
		 Method method = cls.getMethod(fieldSetter, paraTypes) ;
		 String[] paraValues = new String[]{paraValue} ;
		 method.invoke(base, paraValues) ;
		 } catch (Throwable e) {
		 System.err.println(e);
		 }
		 return base ;
		 }
	public static void main(String[] args){
		 son son =(son) util.convertStr2ServiceBean("javabean.reflect.son","setName","wang da sha");
		 System.out.println("son1.getName() :"+son.getName()) ;
		 }
		  

}
